<table width="100%" border="0"  >
  

     <?php
	
	//load default theme from database
	$query = $this->db->get('generalsettings');
	$config = $query->row_array();
	
			
     // $t= getDirectory('themes/');
	 $theme_names=directory_map('./themes/',TRUE);
	   
	   
	   for($i=0;$i<count($theme_names);$i++)
	   {
	   		
				$theme_info=array();
				//we're reading theme info file
				$theme_config = read_file('./themes/'.$theme_names[$i].'/theme.txt');
				
				//doing error handling when theme.txt file is missing.
				if(empty($theme_config))
					$theme_info=array('No Name','No info file found. Check theme folder','read error','read error','read error');

				//doing some pure php code to use php power :).
				//just try to understand it and you will know what the code is doing
				$new=explode("|",$theme_config);
				
				for($j=0;$j<count($new)-1;$j++)
				{
					$f=explode("=",$new[$j]);
					$theme_info[]=trim($f[1]);
				}	
				
			?>
            
				<tr>
                	<td colspan="3" >
                    	<h3>
							<?=$theme_names[$i]?> 
							<?php 
								if($config['ThemeFolder']==$theme_names[$i])
								echo "-> Default theme";
							?>	
						</h3>
					</td>
				</tr>
				
				<tr>
				  <td rowspan="4">
                  <a href="<?=base_url()?>admin/SaveTheme/<?=$theme_names[$i]?>/<?=$theme_info[0]?>">
                  	
					<?php
					$file="./themes/".$theme_names[$i]."/images/screenshot.png";
					$handle = fopen($file,"r");
					if ($handle) 
					{?>
					<img src="<?=base_url()?>themes/<?=$theme_names[$i]?>/images/screenshot.png" alt="<?=$theme_names[$i]?>" />					
					<?php } 
					else 
					{ ?>
                    <img src="<?=base_url()?>themes/default/images/no-screenshot.png" alt="<?=$theme_names[$i]?>" /> 
					<?php }	?>
                  
                  
                  </a>
					
				  <td>Theme Name</td>
                  <td><?=$theme_info[0]?></td>
  </tr>
				<tr>
				  <td>Author</td>
                  <td><?=$theme_info[1]?></td>
  </tr>
				<tr>
				  <td>License</td>
                  <td><?=$theme_info[2]?></td>
  </tr>
				<tr>
				  <td>Theme Description</td>
                  <td><?=$theme_info[4]?></td>
  </tr>
				
							
				
			
			
		<?php
			
			
			
			
			
		}
	   
      
	 
?></table>
